#include "bezierwave.h"
#include "bezierwavebean.h"

BezierWave::BezierWave(QWidget* parent)
    : QWidget { parent }
{
    m_wave = new BezierWaveBean(this);
    m_wave->set_offsety(geometry().height()/20); // 垂直偏移位置【可选】
    m_wave->set_speedx(4); // 设置速度
    m_wave->start();
}


void BezierWave::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing, true); // 抗锯齿

    painter.fillPath(m_wave->getPainterPath(painter), QColor(255, 0, 0, 50));

    return QWidget::paintEvent(event);
}


void BezierWave::resizeEvent(QResizeEvent *e)
{
    m_wave->set_rect(geometry());
    return QWidget::resizeEvent(e);
}
